<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /**
         * 条件判断
         */ 
        let age = 28
        if(age>=60){
            console.log('老年')
        }else if(age>=40){
            console.log('中年')
        }else if(age>=18){
            console.log('少年')
        }else{
            console.log('童年')
        }

        var weekday = 6
        switch(weekday){
            case 1: 
                console.log('周一')
                break
            case 2:
                console.log('周二')
                break
            case 3:
                console.log('周三')
                break
            case 4: 
                console.log('周四')
                break 
            case 5: 
                console.log('周五')
                break
            default:
                console.log('周末')
        }


        /**
         * 循环
         */
        // while、do…while、for 与Java用法一致
        var sum = 0
        var i = 1
        while(i<=10){
            sum += i
            i++
        }
        console.log('从1到10的和为：' + sum)

        // for…in 循环变量表示索引
        var names = ['程煜', '韩笑文', '陆伟铭', '伍嘉欣']
        for(var index in names){
            console.log(index, names[index])
        }

        // for...of 循环变量表示元素
        for(var name of names){
            console.log(name)
        }


    </script>
</body>
</html>